package main

import (
	"fmt"
	"oslab/model"
)

func banker(pro, res int, name []string, ava []int, all, max [][]int, n, req []int) {
	bank := model.NewBank(pro, res, name, ava, all, max)
	bank.Show()
	if bank.Des() {
		fmt.Println("init safe")
	} else {
		fmt.Println("init unsafe")
	}
	for i := 0; i < len(n); i++ {
		fmt.Printf("remaining resources:")
		for j := 0; j < bank.ResourceNums; j++ {
			fmt.Printf("%d ", bank.Available[j])
		}
		fmt.Println()
		fmt.Println("request Process ID:", n[i])
		fmt.Println("request content:", req)
		bank.Request = req
		bank.ReDes(n[i])
		bank.Show()
	}
}
